﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EnglishAuction.BUS
{
    public class CommentBUS
    {
        public static bool Insert(Comment comment)
        {
            bool result = true;
            using (var context = new EnglishAuctionEntities())
            {
                context.Comments.Add(comment);
                context.SaveChanges();
            }

            return result;
        }

        public static List<Comment> GetByProductId(int id)
        {
            List<Comment> lst = new List<Comment>();
            using (var context = new EnglishAuctionEntities())
            {
                lst = context.Comments.Where(c => c.SanPhamId == id).OrderByDescending(p => p.NgayTao).ToList();
            }

            return lst;
        }
    }
}